CSS Style Element if it does not contain another specific type of Element [migrated]
Posted
by
Chris S
on Pro Webmasters
See other posts from Pro Webmasters
or by Chris S
Published on 2012-04-04T15:24:39Z
Indexed on
2012/04/04
17:42 UTC
Read the original article
Hit count: 453
My CSS includes the following:
#mainbody a[href ^='http'] {
background:transparent url('/images/icons/external.svg') no-repeat top right;
padding-right: 12px;
}
This places an "external" icon next to links that start with "http" (all internal site links are relative). Works perfectly except if I link an Image, it also get this icon.
For example: <a href='http://example.com'><img src='whatever.jpg'/></a>
would also get the "external" icon next to the image. I can live with this if necessary, but would like to eliminate it.
This must be implement in CSS (no JS); must not require any special IDs, Classes, styling in the html for the image or anchor around the image. Is this possible?
© Pro Webmasters or respective owner